// /* **********************************************************************************
//  *
//  * Copyright (c) Sky Sanders. All rights reserved.
//  * 
//  * This source code is subject to terms and conditions of the Microsoft Public
//  * License (Ms-PL). A copy of the license can be found in the license.htm file
//  * included in this distribution.
//  *
//  * You must not remove this notice, or any other, from this software.
//  *
//  * **********************************************************************************/
using System;
using System.Collections.Generic;
using System.Configuration;

namespace SimpleRemoteControl.Configuration
{
    public class RemoteControlSection : ConfigurationSection
    {
        public static RemoteControlSection DefaultInstance
        {
            get { return ((RemoteControlSection) ConfigurationManager.GetSection("simpleRemoteControl")); }
        }

        [ConfigurationProperty("browsers", IsRequired = true, IsDefaultCollection = true)]
        public BrowserElementCollection Browsers
        {
            get { return (BrowserElementCollection) this["browsers"]; }
        }

        [ConfigurationProperty("platform", IsRequired = true)]
        public string Platform
        {
            get { return Convert.ToString(this["platform"]); }
            set { this["platform"] = value; }
        }

        [ConfigurationProperty("address")]
        public string Address
        {
            get { return Convert.ToString(this["address"]); }
            set { this["address"] = value; }
        }

        public List<BrowserElement> BrowserList
        {
            get
            {
                List<BrowserElement> returnValue = new List<BrowserElement>();
                foreach (BrowserElement b in Browsers)
                {
                    returnValue.Add(b);
                }
                return returnValue;
            }
        }

        public override bool IsReadOnly()
        {
            return false;
        }

        public BrowserElement GetBrowser(string id)
        {
            return Browsers[id];
        }
    }
}